import time
import unittest
from autoframe.common.functions import open_browser
from autoframe.page.browse_products_page import Browse
from autoframe.page.index_page import IndexPage


class RegisterTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        # 打开浏览器
        driver = open_browser()
        # 创建对象
        cls.browse = Browse(driver)

    def test_01_browse(self):
        # 输入网址
        self.browse.get('http://172.16.140.57/ecshop/')
        # 循环点击9个导航栏里面每一个商品
        self.browse.browse1()

    def test_02_browse(self, navigation=1):
        # 执行第二条测试用例
        # 获取导航栏文本内容
        navigation_text = self.browse.browse2(navigation)
        # 获取面包屑里面的文本
        page_bar_text = self.browse.browse3(navigation)
        # 断言两个文本相同
        self.assertEqual(navigation_text, page_bar_text)

    @classmethod
    def tearDownClass(cls) -> None:
        # 退出浏览器
        cls.browse.quit()


if __name__ == '__main__':
    unittest.main(verbosity=2)
